var name = 'tom'

export function fn() {
  console.log(name)
}

/* 

ESM: 任意一个模块都是一个对象, 任何暴露语法都是向这个对象添加属性/方法

编译后的伪代码
() => {
  var name = 'tom'

function fn() {
  console.log(name)
}

return {
  fn
}

}
*/



export const a1 = 'abc'
export const a2 = 'abc2'

export default function () {}
// export default function fn2 () {}

const a3 = 2
const a4 = 5
export {
  a3,
  a4
}


// import {default as yyy} from '../xxx' // 完整写法
// import jj from './xxx' // 简写

/* 
import * as xxx from 'xxx'
import {a1, a2, a3, a4, default} from 'xxx'
{
  a1, a2, a3, a4, default
}

整个模块永远是一个对象: {}, 任何暴露语法都是向这个对象添加属性/方法
{
  a1: 'abc',
  a2: 'abc2',
  default: function () {},
  a3,
  a4,
}

import {a1, a2, a3, a4} from './test'
import xxx from './test'
// import {default as xxx} from './test
import * as test from './test'
*/

